package com.tai.cobrapp.adapter;

import java.util.ArrayList;

import com.tai.cobrapp.R;
import com.tai.cobrapp.model.Establecimiento;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class EstablishmentSelectionListAdapter extends BaseAdapter {

	Context context = null;
	ArrayList<Establecimiento> data = null;
	LayoutInflater inflater = null;
	
	public EstablishmentSelectionListAdapter(Context context, ArrayList<Establecimiento> data){
		this.context = context;
		this.data = data;
		this.inflater = ((Activity)context).getLayoutInflater();
	}
	
	@Override
	public int getCount() {
		return this.data.size();
	}

	@Override
	public Object getItem(int position) {
		return this.data.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		// Raramente se usa
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		view = inflater.inflate(R.layout.establishment_list_adapter, null);
		
		TextView title = (TextView)view.findViewById(R.id.title_textView);
		title.setText(((Establecimiento)this.getItem(position)).getName().toString());
				
		return view;
	}

}
